import { createRouter, createWebHistory } from "vue-router";
// 管理员
import AdminIndex from "../views/admin/AdminIndex.vue"
import AdminUserInfo from "../views/admin/userInfo/UserInfo.vue"
import AdminBusinessInfo from "../views/admin/businessInfo/BusinessInfo.vue"
import AdminProductInfo from "../views/admin/productInfo/ProductInfo.vue"
import AdminCateInfo from "../views/admin/productInfo/CategoryInfo.vue"
import AdminOrdersInfo from "../views/admin/ordersInfo/OrdersInfo.vue"
import AdminCommentInfo from "../views/admin/ordersInfo/CommentInfo.vue"
// 商家
import BusinessIndex from "../views/business/BusinessIndex.vue"
import ProductManage from "../views/business/products/ProductManageView.vue"
import ProductDetails from "../views/business/products/ProductDetailsView.vue"
import OrdersManage from "../views/business/orders/OrdersManageView.vue"
import BusinessInfo from "../views/business/info/InfoView.vue"
// 用户
import UserIndex from "../views/user/UserIndex.vue"

// 创建路由
const router = createRouter( {
    history: createWebHistory(),
    routes: [
        {
            path: '/login',
            component: () => { return import( '../views/user/login/Login.vue' ) },
        },
        {
            path: '/register',
            component: () => { return import( '../views/user/Register.vue' ) }
        },
        {
            path: '/forget',
            component: () => { return import( '../views/user/Forget.vue' ) }
        },
        {
            path: "/",
            redirect: '/main',
            component: UserIndex,
            children: [
                {
                    path: 'main',
                    component: () => import( '../views/user/Main.vue' )
                },
                {
                    path: 'myInfo',
                    component: () => { return import( '../views/user/info/MyInfo.vue' ) }
                },
                {
                    path: 'cart',
                    component: () => import( '../views/user/cart/Cart.vue' )
                },
                {
                    path: 'collection',
                    component: () => import( '../views/user/collection/Collection.vue' )
                },
                {
                    path: 'order',
                    component: () => { return import( '../views/user/order/Order.vue' ) }
                },
                {
                    name: 'pid',
                    path: 'comment',
                    component: () => { return import( '../views/user/comment/Comment.vue' ) }
                },
                {
                    path: 'address',
                    component: () => { return import( '../views/user/address/Address.vue' ) }
                },
                {
                    name: 'pay',
                    path: 'pay',
                    component: () => { return import( '../views/user/pay/Pay.vue' ) }
                },
                {
                    path: 'paid',
                    component: () => { return import( '../views/user/pay/Paid.vue' ) }
                },
                {
                    path: 'sort',
                    component: () => { return import( '../views/user/sort/Sort.vue' ) },
                },
                {
                    path: 'commodityList',
                    component: () => import( '../views/user/commodity/CommodityList.vue' )
                },
                {
                    path: 'commodityDetail',
                    component: () => import( '../views/user/commodity/CommodityDetail.vue' )
                },
                {
                    path: 'storeList',
                    component: () => import( '../views/user/store/StoreList.vue' )
                },
                {
                    path: 'storeDetail',
                    component: () => import( '../views/user/store/StoreDetail.vue' )
                },
            ]
        },
        {
            path: "/admin/login",
            component: () => { return import( '../views/admin/AdminLogin.vue' ) },
        },
        {
            path: "/admin",
            component: AdminIndex,
            redirect: "/admin/userInfo",
            children: [
                {
                    path: "userInfo",
                    component: AdminUserInfo,
                },
                {
                    path: "businessInfo",
                    component: AdminBusinessInfo,
                },
                {
                    path: "productInfo",
                    component: AdminProductInfo,
                },
                {
                    path: "categoryInfo",
                    component: AdminCateInfo,
                },
                {
                    path: "ordersInfo",
                    component: AdminOrdersInfo,
                },
                {
                    path: "commentInfo",
                    component: AdminCommentInfo,
                },
            ],
        },
        {
            path: "/business/login",
            component: () => { return import( '../views/business/login/Login.vue' ) },
        },
        {
            path: "/business/register",
            component: () => { return import( '../views/business/login/Register.vue' ) },
        },
        {
            path: "/business/forget",
            component: () => { return import( '../views/business/login/Forget.vue' ) },
        },
        {
            path: "/business",
            component: BusinessIndex,
            redirect: "/business/productManage",
            children: [
                {
                    path: "productManage",
                    component: ProductManage,
                },
                {
                    path: "productDetails/:productId*",
                    component: ProductDetails,
                },
                {
                    path: "ordersManage",
                    component: OrdersManage,
                },
                {
                    path: "info",
                    component: BusinessInfo,
                },

            ],
        },
    ]
} )

export default router